.bin-switch {
  display: inline-block;
  width: 44px;
  height: 22px;
  border-radius: 22px;
  vertical-align: middle;
  border: 1px solid var(--bin-border-color-base);
  background-color: var(--bin-fill-color-4);
  position: relative;
  cursor: pointer;
  user-select: none;
  transition: all var(--bin-animation-duration-base) ease-in-out;

  &:after {
    content: '';
    width: 18px;
    height: 18px;
    border-radius: 18px;
    background-color: var(--bin-white-color);
    position: absolute;
    left: 1px;
    top: 1px;
    cursor: pointer;
    transition:
      left var(--bin-animation-duration-base) ease-in-out,
      width var(--bin-animation-duration-base) ease-in-out;
  }

  &:focus {
    box-shadow: 0 0 0 2px var(--bin-color-input-shadow);
    outline: 0;
  }

  &:active:after {
    width: 26px;
  }

  .b-icon-loading {
    position: absolute;
    left: 1px;
    top: 1px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--bin-color-primary);
    z-index: 1;
    width: 18px;
    height: 18px;
    transition:
      left var(--bin-animation-duration-base) ease-in-out,
      width var(--bin-animation-duration-base) ease-in-out;
  }
}

.bin-switch-inner {
  position: absolute;
  left: 23px;
  top: 50%;
  transform: translate3d(0, -50%, 0);
  height: auto;
  color: var(--bin-white-color);
  font-size: 12px;
  display: flex;
  align-items: center;
  line-height: 1;

  i {
    text-align: center;
    position: relative;
    font-size: 14px;
  }
}

.bin-switch-checked {
  border-color: var(--bin-color-primary);
  background-color: var(--bin-color-primary);

  &:after {
    left: 23px;
  }

  &:active:after {
    left: 15px;
  }

  .bin-switch-inner {
    left: 7px;
  }

  .b-icon-loading {
    left: 23px;
  }
}

.bin-switch-large {
  width: 56px;

  .b-icon-loading {
    left: 1px;
  }

  &.bin-switch-checked {
    &:after,
    .b-icon-loading {
      left: 35px;
    }
  }

  &:active {
    &.bin-switch-checked:after {
      left: 23px;
    }

    &:after {
      width: 30px;
    }

    &.bin-switch-disabled,
    &.is-confirm {
      &.bin-switch-checked:after {
        left: 35px;
      }

      &:after {
        width: 18px;
      }
    }
  }
}

.bin-switch-small {
  width: 28px;
  height: 16px;
  line-height: 14px;

  .b-icon-loading {
    left: 1px;
    width: 12px;
    height: 12px;
    font-size: 12px;

    &::before {
      transform: scale(0.6667);
      display: block;
    }
  }

  &.bin-switch-checked {
    &:after,
    .b-icon-loading {
      left: 13px;
    }
  }

  &:after {
    width: 12px;
    height: 12px;
  }

  &:active {
    &.bin-switch-checked:after {
      left: 11px;
    }

    &:after {
      width: 14px;
    }

    &.bin-switch-disabled,
    &.is-confirm {
      &.bin-switch-checked:after {
        left: 13px;
      }

      &:after {
        width: 12px;
      }
    }
  }
}

.bin-switch-default {
  &:active {
    &.bin-switch-disabled,
    &.is-confirm {
      &.bin-switch-checked:after {
        left: 23px;
      }

      &:after {
        width: 18px;
      }
    }
  }
}

.bin-switch-disabled {
  cursor: not-allowed;
  opacity: 0.4;

  &:after {
    cursor: not-allowed;
  }
}

.b-icon-loading {
  animation: rotating 2s linear infinite;
}

@keyframes rotating {
  0% {
    transform: rotateZ(0deg);
  }
  100% {
    transform: rotateZ(360deg);
  }
}
